﻿Imports System.Web.UI.WebControls

Namespace DotNetNuke.Modules.ActiveForums
    Partial Public Class af_polls
        Inherits ForumBase
        Private _pollId As Integer = -1
        Public Property PollId() As Integer
            Get
                Return _pollId
            End Get
            Set(ByVal value As Integer)
                _pollId = value
            End Set
        End Property

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If TopicId > 0 Then
                Try
                    Dim Polls As New Polls
                    Dim ShowResults As Boolean = False
                    If UserId > 0 Then
                        If Polls.HasVoted(TopicId, UserId) Then
                            ShowResults = True
                        End If
                    Else
                        ShowResults = True
                    End If
                    If ShowResults Then
                        Dim lit As New Literal
                        lit.Text = Polls.PollResults(TopicId, ImagePath)
                        Me.Controls.Add(lit)
                    Else
                        'Show Questions
                        Dim ctl As ForumBase = CType(Me.LoadControl("~/DesktopModules/ActiveForums/controls/af_pollvote.ascx"), ForumBase)
                        ctl.ModuleConfiguration = Me.ModuleConfiguration
                        ctl.ForumId = Me.ForumId
                        ctl.TopicId = Me.TopicId
                        Me.Controls.Add(ctl)
                    End If
                Catch ex As Exception

                End Try



            End If

        End Sub

    End Class
End Namespace
